package com.olympus.hermes.product.bean.dto.category;

import com.olympus.hermes.common.bean.AbstractBeanConvert;
import com.olympus.hermes.product.domain.Category;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * @author Mickey
 * @since 2021/1/17
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CategoryTreeTypeDTO extends AbstractBeanConvert<CategoryTreeTypeDTO, Category> {

    private String title;

    private String key;

    private String parentId;

    private List<CategoryTreeTypeDTO> children;

    @Override
    protected Category doForward(CategoryTreeTypeDTO categoryTreeTypeDTO) {
        return null;
    }

    @Override
    protected CategoryTreeTypeDTO doBackward(Category category) {
        this.setKey(category.getId().toString());
        this.setTitle(category.getName());
        this.setParentId(category.getParentId().toString());
        return this;
    }
}
